var sss = 0,
	AliyunImgServer = 'http://pro.mdg-app.com:7001/oss_php_sdk/test2.php?image=', //获取阿里云图片路径接口
	h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
	w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
(function(doc, win) {
	var docEl = doc.documentElement,
		resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
		recalc = function() {
			var clientWidth = docEl.clientWidth;
			if (!clientWidth) return;
			w <= 750 ? (docEl.style.fontSize = 20 * (clientWidth / 750) + 'px') : (docEl.style.fontSize = 10 + 'px');
		};
	sss = 20 * (docEl.clientWidth / 750);
	if (!doc.addEventListener) return;
	win.addEventListener(resizeEvt, recalc, false);
	doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
/**
 * 获取地址栏参数值
 * @param {Object} p
 */

function getURLParam(p) {
	var href = window.location.href,
		s = window.location.search.substr(1),
		reg = new RegExp(p + "=([^&]*)"),
		sp = '?',
		ps = s.match(reg);

	if (ps != null) { // 说明该参数存在
		return ps[1];
	} else {
		return null;
	}
}
/**
 * @description 调用接口获取参数值
 * @param {Object} intername 调用接口名称
 * @param {Object} data 调用数据集
 * @param {Object} success 成功回调函数
 * @param {Object} error 失败回调函数
 */
function getInterFaceData(intername, data, success, error) {
	data = data || {};
	data['in'] = intername; //增加调用参数，将参数名称合并进去
	$.ajax({
		type: "post",
		url: 'ajaxGetData.php',
		dataType: 'json',
		data: data,
		success: success || function() {},
		error: error || function() {}
	});
}
/**
 * @description 获取地址JSON数据
 */
function getAddress(callback) {
	$.ajax({
		url: 'js/city_data.json',
		dataType: 'json',
		success: callback || function() {}
	});
}
/**
 * 阻止默认事件
 * @param {Object} e 事件对象
 */

function _stopDefaultEvent(e) {
	if (e) {
		e.stopPropagation && e.stopPropagation();
		e.preventDefault && e.preventDefault();
		e.stopDefaultEvent && e.stopDefaultEvent();
		e.returnValue = false;
	}
	return false;
}
/**
 * 递归获取地址ID对应的地址名称
 * @param {Object} adds 地址列表
 * @param {Object} id 需要查找的地址名称
 */
function getAddressName(adds, id) {
	if (!adds) return '';
	var adn = '';
	for (var i = 0, l = adds.length; i < l; i++) {
		if (adds[i]['value'] == id) {
			adn = adds[i]['text'];
			break;
		}
		adn = getAddressName(adds[i].children || '', id);
		if (adn) break;
	}
	return adn;
}
/**
 * 获取微信配置信息
 */
function getWeixinConfig(url) {
	url = url || window.location.href;
	$.ajax({
		type: "post",
		url: 'jssdksample.php',
		dataType: 'json',
		data: {
			url: window.location.href
		},
		success: function(data) {
			var wxconfig = {
				appId: data['appId'],
				timestamp: data['timestamp'],
				nonceStr: data['nonceStr'],
				signature: data['signature']
			};
			var shared = qunData ? {
				title: qunData['title'],
				desc: qunData['content'],
				link: url,
				imgUrl: $('.g[data-g=image]').attr('src')
			} : {
				title: '',
				desc: '',
				link: '',
				imgUrl: ''
			};
			WeixinInit(wxconfig, shared);
		},
		error: function() {}
	});
}